﻿using System;
using System.Collections.Generic;
using System.Text;
using org.osgi.framework;

namespace golion.calc.aaasoft
{
    public class Activator : BundleActivator
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        private static BundleContext context;
        private ServiceRegistration calcServiceRegistration;

        public void start(BundleContext context)
        {
            Activator.context = context;
            CalcService calcService = new CalcServiceImpl();
            calcServiceRegistration = context.registerService(typeof(CalcService).FullName, calcService, null);

            DateTime startTime = DateTime.Now;
            for (int i = 0; i < 10000000; i++)
            {
                calcService.Mul(483433, 5843959);
            }
            log.Info("golion.calc:用时：" + (DateTime.Now - startTime).ToString());
        }

        public void stop(BundleContext context)
        {
            calcServiceRegistration.unregister();
            Activator.context = null;
        }
    }
}
